USE <Use Database,,>;

BEGIN TRY
	DECLARE @RQMSID VARCHAR(25) = '<RQMSID,VARCHAR(25),RQMS>'
	DECLARE @NOW DATETIME = CURRENT_TIMESTAMP;
	DECLARE @PRINTSTATEMENT VARCHAR(MAX) = ' | ON: ' + CAST(SERVERPROPERTY('ServerName') AS VARCHAR(128)) + ' | USING: ' + db_Name() + ' | AT: ' + CONVERT(VARCHAR,@NOW,121)

	BEGIN TRANSACTION;

	PRINT 'SUCCESS: Inserted ' + CONVERT(VARCHAR,@@ROWCOUNT) + ' Rows Into #SomeTable Table.' + @PRINTSTATEMENT
	PRINT 'SUCCESS: Updated ' + CONVERT(VARCHAR,@@ROWCOUNT) + ' Rows in CS_PrimaryCostShare Table.' + @PRINTSTATEMENT




	COMMIT TRANSACTION;

END TRY

BEGIN CATCH

	PRINT 'FAILURE: Transaction Failed for the following reasons at ' + @PRINTSTATEMENT
	SELECT
		ERROR_NUMBER(),
		ERROR_PROCEDURE(),
		ERROR_MESSAGE(),
		ERROR_LINE(),
		ERROR_SEVERITY(),
		ERROR_STATE()
	
	IF (XACT_STATE() <> 0 AND @@TRANCOUNT > 0)
	BEGIN
		ROLLBACK TRANSACTION;
		PRINT 'FAILURE: Transaction Rolled Back Successfully at ' + @PRINTSTATEMENT
	END

END CATCH